package com.aaa.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
@Data
public class SecurityUser implements UserDetails {
    //用户名
    private String username;
    //密码
    private String password;
    //是否可用
    private boolean enabled;
    //区分登录
    private String clientId;
   //权限加角色
    private Collection<?extends GrantedAuthority> authorities;
   //用户id
    private Integer uid;

    public SecurityUser(String username, String password, boolean enabled, String clientId, Integer uid) {
        this.username = username;
        this.password = password;
        this.enabled = enabled;
        this.clientId = clientId;
        this.uid = uid;
    }

//    public SecurityUser(String username, String password, boolean enabled, String clientId) {
//        this.username = username;
//        this.password = password;
//        this.enabled = enabled;
//        this.clientId = clientId;
//    }
//
//    public SecurityUser(String username, String password, boolean enabled, String clientId, Collection<? extends GrantedAuthority> authorities) {
//        this.username = username;
//        this.password = password;
//        this.enabled = enabled;
//        this.clientId = clientId;
//        this.authorities = authorities;
//    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.enabled;
    }
}
